home *** CD-ROM | disk | FTP | other *** search
- /*
- * Name: GOPCLI EXEC
- * VM TCP/IP Network GOPHER Client
- * Author: Rick Troth, Rice University, Information Systems
- * Major thanks to Arty Ecock for the wonderful RXSOCKET.
- * Thanks to Serge Goldstein for help with many things.
- * Date: 1992-Dec-23
- */
-
- /*
- * Copyright 1992 Richard M. Troth. This software was developed
- * with resources provided by Rice University and is intended
- * to serve Rice's user community. Rice has benefitted greatly
- * from the free distribution of software, therefore distribution
- * of unmodified copies of this material is not restricted.
- * You may change your own copy as needed. Neither Rice
- * University nor any of its employees or students shall be held
- * liable for damages resulting from the use of this software.
- */
-
- /*
- * Calls:
- * RXSOCKET MODULE -- for TCP/IP network services
- * PIPE MODULE -- for various I/O functions
- * GLOBALV -- for temp and perm global vars
- * XMITMSG -- for all message output
- * VM TCP/IP, V2 or later (through RXSOCKET)
- *
- * GOPCLINI EXEC -- to initialize many things
- * GOPCLITM REXX -- to fetch the first item (a menu)
- * GOPCLIMB REXX -- to display a menu (from bookmarks)
- * both of which call other gems
- *
- * perm GVs:
- * HOST - the host to connect to for the root menu
- * PORT - the port on that host for Gopher service
- * PATH - the path to the initial menu
- * NAME - the name of the initial menu
- * TELNET - the name of the CMS TELNET command (user preference)
- * TN3270 - the name of the command for 3270 telnet connections
- * VIEWER - the CMS command (XEDIT or BROWSE) used to view a file
- * BOOKMARK. - prefix for all bookmark variables, where what
- * follows the dot is the name of the bookmark
- *
- * temp GVs:
- * TUBE - the virtual address of a DIALed terminal (not cons)
- * GOPHER - the IUCV path name and translate table name
- * PROGID - program name
- * ITEM - a line of "gopher menu data" for the chosen item
- * ...
- */
-
- Trace "OFF"
-
- Address "COMMAND"
-
- 'SET LANGUAGE (ADD GOP USER'
- If rc ^= 0 Then Exit rc
-
- 'STATE PIPE MODULE *'
- If rc ^= 0 Then Do
- qrc = rc
- /* "You must have CMS Pipelines to run CMS Gopher." */
- 'XMITMSG 3 (APPLID GOP CALLER CLI ERRMSG'
- Exit qrc
- End /* If .. Do */
-
- /* Thanks to Nick LaFlamme for the linemode catcher. */
- 'PIPE COMMAND QUERY DISPLAY'
- If rc ^= 0 Then Do
- qrc = rc
- 'XMITMSG 523 (ERRMSG' /* "Typewriter mode" */
- /* "CMS Gopher requires a full-screen terminal." */
- 'XMITMSG 926 (APPLID GOP CALLER CLI ERRMSG'
- Exit qrc
- End /* If .. Do */
-
- 'STATE RXSOCKET MODULE *'
- If rc ^= 0 Then Do
- qrc = rc
- /* "You must have RXSOCKET to run CMS Gopher." */
- 'XMITMSG 1 (APPLID GOP CALLER CLI ERRMSG'
- Exit qrc
- End /* If .. Do */
-
- 'STATE TCPIP DATA *'
- If rc ^= 0 Then Do
- qrc = rc
- /* "You must have VM TCP/IP V2 to run CMS Gopher." */
- 'XMITMSG 2 (APPLID GOP CALLER CLI ERRMSG'
- Exit qrc
- End /* If .. Do */
-
- Parse Arg host port path '(' options ')' .
-
- If host = "" & options = "" Then 'GLOBALV SELECT GOPHER GET PATH NAME'
- Else name = ""
-
- /* Initialize some variables */
- bookmark = ""
- bkl = 0
- tube = "CONS"
- quit = 0
-
- /* process options, if any */
- Do While options ^= ""
- Parse Var options op options
- Upper op
- Select /* op */
- When Abbrev("TOPIC",op,2) | ,
- Abbrev("PATH",op,1) Then Do
- path = options
- options = ""
- End /* When .. Do */
- When Abbrev("TUBE",op,2) Then
- Parse Var options tube options
- When Abbrev("BOOKMARK",op,1) | ,
- Abbrev("BKMARK",op,3) Then
- Parse Var options bookmark options
- When Abbrev("BOOKLIST",op,5) | ,
- Abbrev("BKLIST",op,3) Then Do
- bkl = 1
- End /* When .. Do */
- When Abbrev("TITLE",1) Then Do
- name = options
- options = ""
- End /* When .. Do */
- Otherwise 'XMITMSG 3 OP (ERRMSG'
- End /* Select op */
- End /* Do While */
-
- /* initialize many GlobalVs, including screen stem */
- 'EXEC GOPCLINI' tube
-
- /* Now go display first menu or file or bookmark */
- Select
- When bkl Then Call BOOKLIST
- When bookmark ^= "" Then Call BOOKMARK
- Otherwise Call SHOWITEM
- End /* Select */
-
- /* clear some work GlobalVs */
- 'GLOBALV SELECT GOPHER SET PROGID'
- 'GLOBALV SELECT GOPHER SET GOPHER'
- 'GLOBALV SELECT GOPHER SET TUBE'
- 'GLOBALV SELECT GOPHER SET ITEM'
- 'GLOBALV SELECT GOPHER SET COMMAND QUIT' /* no recursion here */
-
- Exit
-
-
-
- /* ------------------------------------------------------------ SHOWITEM
- */
- SHOWITEM:
-
- If host = "" Then 'GLOBALV SELECT GOPHER GET HOST'
- If host = "" Then host = "gopher.tc.umn.edu"
-
- If port = "" Then 'GLOBALV SELECT GOPHER GET PORT'
- If port = "" Then port = 70
-
- If name = "" Then Do
- Parse Value Reverse(path) With name '/' .
- name = Reverse(name)
- End /* If .. Do */
-
- If name = "" Then Do
- 'PIPE COMMAND XMITMSG 4 (APPLID GOP CALLER CLI | VAR NAME'
- Parse Var name . name
- End /* If .. Do */
-
- type = Left(path,1)
- If type = '/' | type = ' ' Then type = '1'
-
- item = type || name || '05'x || path || '05'x ,
- || host || '05'x || port || '05'x
- 'PIPE VAR ITEM | GOPCLITM OPEN | CONSOLE'
-
- Return
-
-
-
- /* ------------------------------------------------------------ BOOKMARK
- * Present the selected bookmark or fall-back to the list of all.
- */
- BOOKMARK:
-
- /* if bookmark was specified numeric, just fetch it */
- If Datatype(bookmark,'N') Then Do
- i = Trunc(bookmark)
- 'PIPE COMMAND GLOBALV SELECT GOPHER GET BOOKMARK.' || i
- If bookmark.i ^= "" Then Do
- 'PIPE VAR BOOKMARK.' || i '| GOPCLITM OPEN | CONSOLE'
- Return
- End /* If .. Do */
- End /* If .. Do */
-
-
-
- /* ------------------------------------------------------------ BOOKLIST
- * Present a menu of all of the user's bookmarks.
- */
- BOOKLIST:
-
- If name = "" Then Do
- /* extract personal name from NAMES file */
- Parse Value Diag(08,'QUERY USERID') With user . host . '15'x .
- 'PIPE COMMAND NAMEFIND :USERID' user ':NODE' host ,
- ':NAME | VAR PERSONAL'
- If rc = 0 & personal ^= "" Then
- /* make a title line for bookmark list */
- 'PIPE COMMAND XMITMSG 40 PERSONAL' ,
- '(APPLID GOP CALLER CLI NOHEADER | VAR NAME'
- End /* If .. Do */
-
- /* extract bookmarks from GlobalVs */
- 'PIPE COMMAND GLOBALV SELECT GOPHER LIST' ,
- '| LOCATE 1-10 / BOOKMARK./ | SPEC /=/ 1 2-* NEXT | VARLOAD'
- If ^Datatype(bookmark.0,'N') Then bookmark.0 = 0
- Else bookmark.0 = Trunc(bookmark.0)
-
- 'PIPE STEM BOOKMARK. | GOPCLIMB' name '| CONSOLE'
- If rc ^= 0 Then Return
-
- 'GLOBALV SELECT GOPHER GET COMMAND'
- Parse Upper Var command verb .
- If Abbrev("QUIT",verb,1) Then Return
-
- /* remove any blanked (deleted) bookmarks from the stem */
- j = 0
- 'GLOBALV SELECT GOPHER GET BOOKMARK.0'
- Do i = 1 to bookmark.0
- 'GLOBALV SELECT GOPHER GET BOOKMARK.' || i
- If Symbol("BOOKMARK." || i) = "LIT" | ,
- bookmark.i = "" | ,
- Left(bookmark.i,1) = 'i' Then Iterate
- j = j + 1
- bookmark.j = bookmark.i
- 'GLOBALV SELECT GOPHER PUTP BOOKMARK.' || j
- End
- bookmark.0 = j
- 'GLOBALV SELECT GOPHER PUTP BOOKMARK.0'
-
- Return
-
-